
Page({

  /**
   * 页面的初始数据
   */
  data: {
    zh: '',
    schema:[],
    formData:{
      enableDebug: false
    },
    title: '',
    result: '',
    remark: '',
    webUrl: '',
    apiName: '',
    showPrivacy: false
  },
  onUnload() {
  },
  onLoad(options) {
    console.log('options', options)
    wx.setNavigationBarTitle({
      title: options.title,
    })
    
    this.setData({
      title: options.title,
      zh:options.zh,
      remark: options.remark,
      webUrl: options.webUrl
    })
    if(options.zh === 'wx.setEnableDebug') {
      this.setData({
        schema: [
          {
            label:'是否打开调试',
            prop:'enableDebug',
            type:'switch'
          },
        ]
      })
    }
  },
  getFormData(e) {
    console.log('formdata==', e.detail.formData);
    this.setData({
      formData: e.detail.formData
    })
  },
  setEnableDebug(e) {
    const that = this;
    wx.setEnableDebug({
      enableDebug: this.data.formData.enableDebug,
      success(res) {
        that.setData({
          result: res,
          apiName: e.currentTarget.dataset.apiname
        })
      },
      fail(res) {
        that.setData({
          result: res,
          apiName: e.currentTarget.dataset.apiname
        })
      }
    })
  },
  getRealtimeLogManager(e) {
    const logger = wx.getRealtimeLogManager();
    this.setData({
      result: logger,
      apiName: e.currentTarget.dataset.apiname
    })
  },
  debug(e) {
    console.debug('debug')
    this.setData({
      result: '在vConsole中查看',
      apiName: e.currentTarget.dataset.apiname
    })
  },
  error(e) {
    console.error('error')
    this.setData({
      result: '在vConsole中查看',
      apiName: e.currentTarget.dataset.apiname
    })
  },
  group(e) {
    console.group('group')
    console.log('log1')
    console.log('log2')
    console.log('log3')
    console.log('log4')
    console.groupEnd()
    this.setData({
      result: '在vConsole中查看',
      apiName: e.currentTarget.dataset.apiname
    })
  },
  groupEnd(e) {
    console.group('group')
    console.log('log1')
    console.log('log2')
    console.log('log3')
    console.log('log4')
    console.groupEnd()
    this.setData({
      result: '在vConsole中查看',
      apiName: e.currentTarget.dataset.apiname
    })
  },
  info(e) {
    console.info('info')
    this.setData({
      result: '在vConsole中查看',
      apiName: e.currentTarget.dataset.apiname
    })
  },
  log(e) {
    console.log('log')
    this.setData({
      result: '在vConsole中查看',
      apiName: e.currentTarget.dataset.apiname
    })
  },
  warn(e) {
    console.warn('warn')
    this.setData({
      result: '在vConsole中查看',
      apiName: e.currentTarget.dataset.apiname
    })
  },
  LogManagerdebug(e) {
    const LogManager = wx.getLogManager()
    LogManager.debug('debug')
    this.setData({
      result: '在vConsole中查看',
      apiName: e.currentTarget.dataset.apiname
    })
  },
  LogManagerinfo(e) {
    const logger = wx.getLogManager(); // 获取日志管理器
    logger.info('用户点击了按钮', { userId: 123 }, ['额外数据']); // 记录info日志
    this.setData({
      result: '在vConsole中查看',
      apiName: e.currentTarget.dataset.apiname
    })
  },
  LogManagerlog(e) {
    const logger = wx.getLogManager(); // 获取日志管理器
    logger.log('用户点击了按钮', { userId: 123 }, ['额外数据']); // 记录info日志
    this.setData({
      result: '在vConsole中查看',
      apiName: e.currentTarget.dataset.apiname
    })
  },
  LogManagerwarn(e) {
    const logger = wx.getLogManager(); // 获取日志管理器
    logger.warn('用户点击了按钮', { userId: 123 }, ['额外数据']); // 记录info日志
    this.setData({
      result: '在vConsole中查看',
      apiName: e.currentTarget.dataset.apiname
    })
  },
  RealtimeLogManagerAddFilterMsg(e) {
    const logger = wx.getRealtimeLogManager();
    logger.addFilterMsg('testKeyword'); // 记录info日志
    this.setData({
      result: '开发者可从We分析“性能质量->实时日志->小程序日志”进入小程序端日志查询页面查看',
      apiName: e.currentTarget.dataset.apiname
    })
  },
  RealtimeLogManagerError(e) {
    const logger = wx.getRealtimeLogManager();
    logger.error('error'); // 记录info日志
    this.setData({
      result: '开发者可从We分析“性能质量->实时日志->小程序日志”进入小程序端日志查询页面查看',
      apiName: e.currentTarget.dataset.apiname
    })
  },
  RealtimeLogManagerInfo(e) {
    const logger = wx.getRealtimeLogManager();
    logger.info('info'); // 记录info日志
    this.setData({
      result: '开发者可从We分析“性能质量->实时日志->小程序日志”进入小程序端日志查询页面查看',
      apiName: e.currentTarget.dataset.apiname
    })
  },
  RealtimeLogManagerSetFilterMsg(e) {
    const logger = wx.getRealtimeLogManager();
    logger.setFilterMsg('testKeyword'); // 记录info日志
    this.setData({
      result: '开发者可从We分析“性能质量->实时日志->小程序日志”进入小程序端日志查询页面查看',
      apiName: e.currentTarget.dataset.apiname
    })
  },
  RealtimeLogManagerWarn(e) {
    const logger = wx.getRealtimeLogManager();
    logger.warn('warn'); // 记录info日志
    this.setData({
      result: '开发者可从We分析“性能质量->实时日志->小程序日志”进入小程序端日志查询页面查看',
      apiName: e.currentTarget.dataset.apiname
    })
  },

  RealtimeTagLogManagerAddFilterMsg(e) {
    const logger = wx.getRealtimeLogManager();
    const tag = logger.tag('tagTest')
    tag.addFilterMsg('testTagKeyword');
    this.setData({
      result: '开发者可从We分析“性能质量->实时日志->小程序日志”进入小程序端日志查询页面查看',
      apiName: e.currentTarget.dataset.apiname
    })
  },
  RealtimeTagLogManagerError(e) {
    const logger = wx.getRealtimeLogManager();
    const tag = logger.tag('tagTest')
    tag.error('errorKey', 'error'); // 记录info日志
    this.setData({
      result: '开发者可从We分析“性能质量->实时日志->小程序日志”进入小程序端日志查询页面查看',
      apiName: e.currentTarget.dataset.apiname
    })
  },
  RealtimeTagLogManagerInfo(e) {
    const logger = wx.getRealtimeLogManager();
    const tag = logger.tag('tagTest')
    tag.info('infoKey','info'); // 记录info日志
    this.setData({
      result: '开发者可从We分析“性能质量->实时日志->小程序日志”进入小程序端日志查询页面查看',
      apiName: e.currentTarget.dataset.apiname
    })
  },
  RealtimeTagLogManagerSetFilterMsg(e) {
    const logger = wx.getRealtimeLogManager();
    const tag = logger.tag('tagTest')
    tag.setFilterMsg('testTagKeyword'); // 记录info日志
    this.setData({
      result: '开发者可从We分析“性能质量->实时日志->小程序日志”进入小程序端日志查询页面查看',
      apiName: e.currentTarget.dataset.apiname
    })
  },
  RealtimeTagLogManagerWarn(e) {
    const logger = wx.getRealtimeLogManager();
    const tag = logger.tag('tagTest')
    tag.warn('warnKey', 'warn'); // 记录info日志
    this.setData({
      result: '开发者可从We分析“性能质量->实时日志->小程序日志”进入小程序端日志查询页面查看',
      apiName: e.currentTarget.dataset.apiname
    })
  },
})